function voutputgender(fvideo, fvideoout, fdata, nstart, nend, bdrawellipse, bdrawareas)


v = mmreader(fvideo);
load(fdata)


aviobj = avifile(fvideoout, 'fps', 30);


fig = figure;

r = 255;
g = 255;
b = 255;
linethickness = 3;


asz = size(areasx0);
ntypes = asz(3);

for i = nstart:nend 
    vindex = i+nprocessstart-1;   
    vindex
    img = read(v,vindex);
    img2 = img;
      
    imgsz = size(img);
    xl = imgsz(1);
    yl = imgsz(2);


    nobjs = objs(i);
    
    for j = 1:nobjs       
        
            if bdrawareas == 1 
                for k = 1:ntypes
                
                    bDraw = 1;
                    linethickness = 1;
                 
                    index = i;
                    if bwarnings(index, j, k) ~= 0 | areasx1(index,j, k) == 0 | areasy1(index,j, k) == 0
                        bDraw = 0;
                    end
            
                    if bDraw == 1 
            
                        x1 = x1s(index,j);
                        x2 = x2s(index,j);
                        y1 = y1s(index,j);
                        y2 = y2s(index,j);   
       
                        ax1 = areasx1(index,j, k) + x1;
                        ax2 = areasx2(index,j, k) + x1;
                        ay1 = areasy1(index,j, k) + y1;
                        ay2 = areasy2(index,j, k) + y1;
            
                        if k == 1
                            r = 250;
                            g = 110;
                            b = 110;
                        elseif k == 2
                            r = 110;
                            g = 250;
                            b = 100;
                        elseif k == 3
                            r = 110;
                            g = 110;
                            b = 250;
                        elseif k == 4
                            r = 240;
                            g = 240;
                            b = 130;    
                        else
                            r = 255;
                            g = 255;
                            b = 255;    
                        end
                            
                        if ax1 > 0 & areasx1(index,j, k) > 0 & areasy1(index,j, k) > 0
                            img2 = DrawThickColorRGBBox(img2,  ax1, ay1, ax2, ay2, r, g, b, 3, xl, yl);
                        end
                    end
                end                
            end
            
            if bdrawellipse == 1                
                
                if gendertypes(i,j) == 0 %female
                    r = 255;
                    g = 160;
                    bb = 160;
                elseif gendertypes(i,j) == 1
                    r = 135;
                    g = 250;
                    bb = 135;
                else
                    r = 255;
                    g = 255;
                    bb = 255;
                end
                
                x0 = ex0s(i,j);
                y0 = ey0s(i,j);
                phi = ephis(i,j);
                a = eas(i,j);
                b = ebs(i,j);
                img2 = DrawImgEllipseColor(img2, x0, y0, a, b, phi, r, g, bb);
                                                                                      
            else
                x1 = x1s(i,j);
                x2 = x2s(i,j);
                y1 = y1s(i,j);
                y2 = y2s(i,j);
                
                 
                if gendertypes(i,j) == 0 %female
                    r = 255;
                    g = 160;
                    b = 160;
                elseif gendertypes(i,j) == 1
                    r = 135;
                    g = 250;
                    b = 135;
                else
                    r = 255;
                    g = 255;
                    b = 255;
                end
                
                img2 = DrawThickColorRGBBox(img2,  x1, y1, x2, y2, r, g, b, linethickness, xl, yl);
            end
    end
    
    imshow(img2)
    f = getframe(fig);
    aviobj = addframe(aviobj,f);  
end

aviobj = close(aviobj);
aviobj

close(fig)